<!doctype html>
<html lang="en"><head>
    <meta charset="UTF-8">
    <meta content="telephone=no" name="format-detection">
    <meta content="IE=EmulateIE11" http-equiv="X-UA-Compatible">
    <title>欢迎登录代理商管理系统</title>
    <script src="../public/all/js/jquery-3.1.1.min.js"></script>
    <script src="../public/all/js/jquery.cookie.js"></script>
    <script src="js/referee.min.js"></script>

    <!-- debug only -->
    <script src="../public/all/js/context.js"></script>
    <script src="../public/all/js/util.js"></script>
    <script src="../public/all/js/cmd.js"></script>
    <!-- debug only end -->

    <link rel="stylesheet" href="css/main.css">
    <link rel="stylesheet" href="css/login.css">
</head>

<body id="login">
    <div>
        <div id="mainBody">
            <div class="nprogress-container"></div> 
            <div class="cloud" style="background-position: 1200.4px 100px;"></div> 
            <div class="cloud" style="background-position: 1073.8px -50px;"></div>
        </div> 
        
        <div class="logintop">
            <span>欢迎登录代理商管理系统</span> 
            <ul>
                <li><a href="#">回首页</a></li> 
                <li><a href="#">帮助</a></li> 
                <li><a href="#">关于</a></li>
            </ul>
        </div> 
        
        <div class="loginbody">
            <form name="loginForm" class="loginbox">
                <ul>
                    <li>
                        <input id="userName" name="name" type="text" value="" class="loginuser"> 
                        <p style="margin-bottom: -10px;">
                            <span style="color: rgb(255, 0, 0);"></span>
                        </p>
                    </li> 
                    
                    <li>
                        <input id="userPwd" type="password" name="password" value="" class="loginpwd"> 
                        <p style="margin-bottom: -10px;"><span style="color: rgb(255, 0, 0);"></span></p>
                    </li> 
                                        
                    <li class="ctrl">
                        <input id="loginBtn" type="button" value="登录" class="loginbtn"> 
                        <a href="javascript:alert('请联系维护人员');">忘记密码？</a>
                    </li>
                </ul>
            </form>
        </div>
    </div>
</body></html>

<script>
    $("#loginBtn").click(function() {
        var uid = $("#userName").val().trim();
        var p = $("#userPwd").val().trim();
        if (!uid) {
            alert("请输入登录账号！");
            return;
        }
        if (!p) {
            alert("请输入登录密码！");
            return;
        }

        CMD.signin(uid, p, "pc",
            function(r) {
                console.log("登录成功", r);
                if (r.grade != 49 && false) {
                     // TODO
                    alert("您不是代理用户！")
                    return;
                }
                Util.jumpUrl({ file: 'main.html'});
            }, function(message) {
                if (message) alert(message);
                else alert("登录失败！");
            });
    });
</script>